import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab

# 绘图参数全家桶
params = {
    'axes.labelsize': '14',
    'xtick.labelsize': '12',
    'ytick.labelsize': '12',
    'legend.fontsize': '12',
    'figure.figsize': '6, 4',
    'figure.dpi': '180',
    'figure.subplot.left': '0.154',
    'figure.subplot.right': '0.982',
    'figure.subplot.bottom': '0.219',
    'figure.subplot.top': '0.974',
    'pdf.fonttype': '42',
    'ps.fonttype': '42',
    'font.family': ['Times New Roman', 'SimSun'],
    'mathtext.fontset': 'cm'
}
pylab.rcParams.update(params)

color_1 = "#FF6666"
color_2 = "#6699FF"
color_3 = "#EECC66"
color_4 = "#66CC99"

fig, ax = plt.subplots()

# 折线图
x = np.arange(10) + 1  # the label locations
data = [[97.81, 98.73, 98.85, 99.11, 99.2, 99.14, 99.2, 99.24, 99.32, 99.3],
        [9.67, 10.29, 17.87, 86.93, 97.69, 96.59, 99.86, 99.32, 99.68, 99.66]]
plt.plot(x, data[0], linewidth=2.0, color=color_2, marker='s',
         markerfacecolor=color_2, markeredgewidth=1.5, markersize=8, label='Clean Accuracy')
plt.plot(x, data[1], linewidth=2.0, color=color_1, marker='o',
         markerfacecolor=color_1, markeredgewidth=1.5, markersize=8, label="Attack Success Rate")

ax.set_xticks([0, 2, 4, 6, 8, 10])
ax.set_xticklabels(['$0$', '$2$', '$4$', '$6$', '$8$', '$10$'])
ax.set_yticks([0, 20, 40, 60, 80, 100])
ax.set_yticklabels(['$0\\text{%}$',
                    '$20\\text{%}$',
                    '$40\\text{%}$',
                    '$60\\text{%}$',
                    '$80\\text{%}$',
                    '$100\\text{%}$'])
ax.set_xlabel('Epoch Number')

plt.xlim((0, 11))
plt.ylim((0, 110))

plt.legend(loc='lower right', ncol=1, columnspacing=1, prop={'size': 10})

plt.grid(linestyle="--", linewidth=0.5, color='black', alpha=0.5)

plt.tight_layout()

plt.savefig("./size=1, ratio=0015.png", format='png')

plt.show()
